/***************************************************************************
 * 
 * Copyright (c) 2011 Baidu.com, Inc. All Rights Reserved
 * common.h,v 1.0 2012-08-17 11:31 yelu01 
 * 
 **************************************************************************/
 
 
 
/**
 * @file Error.h
 * @author yelu01(yelu01@baidu.com)
 * @date 2012-08-17 11:31
 * @version 1.0 
 * @brief err code.
 *  
 **/

#pragma once

#include <cstring>

class Error
{
public:
    enum Type
    {
       NO_ERR,
    };

    Error(Type t = NO_ERR, const char* msg = "")
	{
		_type = t;
		strncpy(_msg, msg, sizeof(_msg));
		_msg[sizeof(_msg) - 1] = '\0';
	}
	
	Error(const Error& error)
	{
		this->_type = error._type;
		strncpy(this->_msg, error._msg, sizeof(_msg));
		_msg[sizeof(_msg) - 1] = '\0';
	}
	
	const Error& operator = (const Error& error)
	{
		this->_type = error._type;
		strncpy(this->_msg, error._msg, sizeof(_msg));
		_msg[sizeof(_msg) - 1] = '\0';
		return *this;
	}
	
	Type type()
	{
		return _type;
	}
	
	const char* what()
	{
		return _msg;
	}

private:
    Type _type;
    char _msg[1024];
};
